package com.syxd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.syxd.common.service.impl.CrudServiceImpl;
import com.syxd.dao.SysRoleDao;
import com.syxd.dto.SysRoleDTO;
import com.syxd.entity.SysRoleEntity;
import com.syxd.service.SysRoleService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * 系统角色表
 *
 * @author hr tecsmile@outlook.com
 * @since 1.0.0 2019-07-15
 */
@Service
@Transactional
public class SysRoleServiceImpl extends CrudServiceImpl<SysRoleDao, SysRoleEntity, SysRoleDTO> implements SysRoleService {

    @Override
    public QueryWrapper<SysRoleEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("role_id");

        QueryWrapper<SysRoleEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "role_id", id);

        return wrapper;
    }

    @Override
    public Long save(SysRoleEntity role) {
        return baseDao.save(role);
    }
}
